package com.zegome.game.gomestory.main;

import java.util.Vector;

import android.graphics.Bitmap;
import android.util.Log;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
import com.zegome.secure.ExternalFileEncrypt;

public class A {	
	Center ctr;
	//==========INFO===============
	public boolean 
	isLoadedSplash,
	isLoadedCommond1,
	isLoadedCommond2,
	isLoadedMusic1,
	isLoadedMusic2,
	isLoadedMenu,
	isLoadedChapter,
	isLoadedLevel,
	isLoadedGame,
	isLoadedVS,
	isLoadedDraw,
	isDeleteSplash,
	isDeleteCommond1,
	isDeleteCommond2,
	isDeleteMusic1,
	isDeleteMusic2,
	isDeleteMenu,
	isDeleteChapter,
	isDeleteLevel,
	isDeleteGame,
	isDeleteVS,
	isDeleteDraw;;
	//==========MUSIC==============
	public Music bgSong;
	public Sound yesSound;
	public Sound noSound;
	public Sound findSound;
	public Sound[] eatSound;
	public Music mainSong;
	public Sound selectSound;
	public Sound wrongSound;
	public Sound kiem_chem;
	//public Music bgDrawSong;
	//public Music bgVsSong, bgChapterSong; 
	public Sound lose;
	public Sound win;
	//===========COMMOND===========
	
	public TextureRegion bgAchieve;
	
	public TextureRegion transRegion;
	public TextureRegion blackRegion;

	public TextureRegion sticky, arrowDown, arrowLeft,ok;
	public TextureRegion[] star;
	public TextureRegion hand;
	
	public TextureRegion topText;
	public TextureRegion nameGame;
	public TextureRegion bgItemHelp;
	public TextureRegion topUser;
	public TextureRegion closeDialog;
	public TextureRegion onlineGomeMoney;
	public TextureRegion gomeShopIcon;
	public TextureRegion elGPPay;
	public TextureRegion elGPPayPress;
	public TextureRegion oneGomeMoney;
	public TextureRegion buyMoney;
	public TextureRegion twoGomeMoney;
	public TextureRegion threeGomeMoney;
	public TextureRegion fourGomeMoney;
	public TextureRegion boderAvatar;
	public TextureRegion bgDialog_uof;
	public TextureRegion bgDialogNoBoder;
	public TextureRegion nextDialog_uof;
	public TextureRegion replayDialog_uof;
	public TextureRegion menuDialog_uof;
	public TextureRegion gomeLoseDialog_uof;
	public TextureRegion gomeWinDialog_uof;
	public TextureRegion loginPopUpNor;
	public TextureRegion loginPopUpPress;
	public TextureRegion shareFb,shareFBPress;
	public TextureRegion logoutPopUpNor;
	public TextureRegion logoutPopUpPress;
	public TextureRegion blankSmallButton;
	public TextureRegion settingIcon;
	
	public TextureRegion loginNorDialog_uof;
	public TextureRegion loginPressDialog_uof;
	public TextureRegion regNorDialog_uof;
	public TextureRegion regPressDialog_uof;
	public TextureRegion loginBgDialog_uof;
	public TextureRegion buttonBlank;
	
	public TextureRegion okNorRegion;
	public TextureRegion okPressRegion;
	public TextureRegion noNorRegion;
	public TextureRegion noPressRegion;
	public TextureRegion avatarFrame;
	public Texture avatarTexture;
	public TextureRegion avatarMe;
	public TextureRegion avatarDefault;
	public Texture avatarBossTexture;
	public TextureRegion avatarBoss;
	public TextureRegion fbAttackIcon;
	public TextureRegion iconGomeMoney;
	public TextureRegion bgCommondRegion;
	public TextureRegion iconSmallGome;
	
	public TextureRegion textBet;
	public TextureRegion textBetPress;
	
	public TextureRegion onlineNorRegion;
	public TextureRegion onlinePressRegion;
	
	public TextureRegion playNorRegion;
	public TextureRegion playPressRegion;
	
	public TextureRegion specialNorRegion;
	public TextureRegion specialPressRegion;
	
	public TextureRegion vsNorRegion;
	public TextureRegion vsPressRegion;
	
	public TextureRegion createMapNor;
	public TextureRegion createMapPress;
	
	// ~ setting
	public TextureRegion downloadNorRegion;
	public TextureRegion downloadPressRegion;	
    // ~ info
	public TextureRegion infoNorRegion;
	public TextureRegion infoPressRegion;	
	// ~ Music
	public TextureRegion friendNorRegion;
	public TextureRegion friendPressRegion;	
	// ~ Volume
	public TextureRegion exitNorRegion;
	public TextureRegion exitPressRegion;	
	// ~ Help
	public TextureRegion sharedNorRegion;	
	public TextureRegion sharedPressRegion;	
	//
	public TextureRegion updateIcon;
	//
	public TextureRegion shopButtonNor;
	public TextureRegion shopButtonPress;
	public TextureRegion changeAvatarNor;
	public TextureRegion changeAvatarPress;
	public TextureRegion askFBNor;
	public TextureRegion askFBPress;
	public TextureRegion addGoldNor;
	public TextureRegion addGoldPress;
	public TextureRegion cuponNor;
	public TextureRegion cuponPress;
	//
	public TextureRegion settingRegion;	
	public TextureRegion starRegion;
	public TextureRegion[] bgRegion;
	public TextureRegion[][] iconRegion;
	public boolean[] isLoadedBg;
	public boolean[] isDeleteBg;
	public boolean[] isLoadedIcon;
	public boolean[] isDeleteIcon;
	public String[] nameRegionBg;
	public TextureRegion paypal,paypalPress;
	public TextureRegion scratch, scratchPress;
	public TextureRegion sms, smsPress;
	public TextureRegion bank, bankPress;
	public TextureRegion resetPass, resetPass2;
	
	public TextureRegion[] achievement;
	//===========SPLASH============	
	public Texture splash1, splash2, splash3;
	public TextureRegion bgSplash;
	public TextureRegion logoSplash[];
	//===========MENU==============	
	public TextureRegion bgMenu;
	public TextureRegion logoRegion;			
	//
	public TextureRegion facebook;
	
	public TextureRegion fbShareMenu; 
	//===========VS==============	
	public TextureRegion iconBigGomeMoney;
	public TextureRegion bgVSRegion;
	public TextureRegion vRegion;
	public TextureRegion sRegion;
	public TextureRegion frameInfoRegion;
	public TextureRegion balanceRegion;
	public TextureRegion bigDiamond;
	public TextureRegion sameRegion;
	public TextureRegion bgItemBet;
	public TextureRegion bgItemBetPress;
	public TextureRegion betButton;
	//============CHAPTER==========
	public TextureRegion iconLockChapterRegion;
	public TextureRegion pika1Region;
	public TextureRegion pika2Region;
	public TextureRegion pika3Region;
	public TextureRegion pika4Region;
	public TextureRegion pika5Region;
	public TextureRegion pika6Region;
	public TextureRegion pika7Region;
	public TextureRegion pika8Region;
	//============LEVEL============
	public TextureRegion ball0Region;
	public TextureRegion ball1Region;
	public TextureRegion ball2Region;
	public TextureRegion ball3Region;
	public TextureRegion ball4Region;
	public TextureRegion ball5Region;
	public TextureRegion ball6Region;
	//===========GAME==============
	public TextureRegion bg1TL, bg1TR, bg1BL, bg1BR, bg2WT, bg2WL, bg2WB, bg2WR, bg4Gome, bg0Gome, conTL, conTR, conBL, conBR;
	public TextureRegion bgCombo;
	public TextureRegion kha;
	public TextureRegion tot;
	public TextureRegion tuyetvoi;
	public TextureRegion hoanhao;
	public TextureRegion verRegion;
	public TextureRegion swap;
	public TextureRegion find;
	public TextureRegion clockBound;
	public TextureRegion clockCore;
	public TextureRegion horRegion;
	public TextureRegion[] squareRegion;
	public TextureRegion[] boom1;
	public TextureRegion[] boom2;
	public TextureRegion[] boom3;
	public TextureRegion[] boom4;
	public TextureRegion[] boom5;
	public TextureRegion[] boom6;
	public TextureRegion[] slash;
	// DRAW
	public TextureRegion prev, next;
	public TextureRegion bgDraw;
	public TextureRegion boundSquare;
	public TextureRegion brush, eraser, cancel;
	public TextureRegion football;
	public TextureRegion grid, gomePainter;
	public TextureRegion bgNameMap;
	public TextureRegion[] templateIcon;
	public int currentChapter=-1;
	public TextureRegion fbShared;
	public TextureRegion bgAllMap;
	
	public A(Center ctr){
		this.ctr = ctr;
	}
	
	public void loadRSGame(int level, boolean isLevel){		
		int chapter;
		if(isLevel)
			chapter= (level-1)/20;
		else
			chapter = level;
		if(chapter==currentChapter){}
		else{
			if(currentChapter!=-1){
				unloadRSGame(1+currentChapter*20);
			}
			loadBg(chapter);
			loadIcon(chapter);
		}
		currentChapter = chapter;
	}
	
	public void loadedRSGame(int level, boolean isLevel){
		int chapter;
		if(isLevel)
			chapter= (level-1)/20;
		else
			chapter = level;
		loadedBg(chapter);
		loadedIcon(chapter);
		currentChapter = chapter;
	}
	
	public void unloadRSGame(int level){
		int chapter = (level-1)/20;
		unloadBg(chapter);
		unloadIcon(chapter);
		currentChapter = -1;
	}
	
	public void clearMusic2(){
		if(isDeleteMusic2 == false){
			findSound = null;
			for(int i=0;i<10;i++){
				eatSound[i] = null;
			}
			mainSong = null;
			selectSound = null;
			wrongSound = null;
			win = null;
			lose = null;
			isDeleteMusic2 = true;
		}
	}
	public void unloadMusic2(){
		if(isLoadedMusic2 == true){
			ctr.controller.unload("data/music/gamebg.ogg");			
			ctr.controller.unload("data/music/bom.wav");
			ctr.controller.unload("data/music/wrong.mp3");
			ctr.controller.unload("data/music/select.mp3");
			ctr.controller.unload("data/music/tinh1.ogg");
			ctr.controller.unload("data/music/tinh2.ogg");
			ctr.controller.unload("data/music/tinh3.ogg");
			ctr.controller.unload("data/music/tinh4.ogg");
			ctr.controller.unload("data/music/tinh5.ogg");
			ctr.controller.unload("data/music/tinh6.ogg");
			ctr.controller.unload("data/music/tinh7.ogg");
			ctr.controller.unload("data/music/tinh8.ogg");
			ctr.controller.unload("data/music/tinh9.ogg");
			ctr.controller.unload("data/music/tinh10.ogg");
			ctr.controller.unload("data/music/win.ogg");
			ctr.controller.unload("data/music/lose.mp3");
			clearMusic2();
			
			isLoadedMusic2 = false;
		}
	}
	public void loadMusic2(){
		if(isLoadedMusic2 == false ){
		ctr.controller.load("data/music/gamebg.ogg", Music.class);
		
		ctr.controller.load("data/music/bom.wav", Sound.class);
		ctr.controller.load("data/music/wrong.mp3", Sound.class);
		
		ctr.controller.load("data/music/select.mp3", Sound.class);

		
		ctr.controller.load("data/music/tinh1.ogg", Sound.class);
		ctr.controller.load("data/music/tinh2.ogg", Sound.class);
		ctr.controller.load("data/music/tinh3.ogg", Sound.class);
		ctr.controller.load("data/music/tinh4.ogg", Sound.class);
		ctr.controller.load("data/music/tinh5.ogg", Sound.class);
		ctr.controller.load("data/music/tinh6.ogg", Sound.class);
		ctr.controller.load("data/music/tinh7.ogg", Sound.class);
		ctr.controller.load("data/music/tinh8.ogg", Sound.class);
		ctr.controller.load("data/music/tinh9.ogg", Sound.class);
		ctr.controller.load("data/music/tinh10.ogg", Sound.class);
		ctr.controller.load("data/music/win.ogg", Sound.class);
		ctr.controller.load("data/music/lose.mp3", Sound.class);
		}
	}
	public void loadedMusic2(){
		if(isLoadedMusic2 == false|| (isLoadedMusic2 == true && isDeleteMusic2 == true)){
		findSound = ctr.controller.get("data/music/bom.wav", Sound.class);
		eatSound = new Sound[10];
		for(int i=0;i<10;i++){
			eatSound[i] = ctr.controller.get("data/music/tinh"+(i+1)+".ogg", Sound.class);
		}
		mainSong = ctr.controller.get("data/music/gamebg.ogg", Music.class);
		try{
		mainSong.setLooping(true);
		}
		catch(Exception ex){}
		selectSound = ctr.controller.get("data/music/select.mp3", Sound.class);
		wrongSound = ctr.controller.get("data/music/wrong.mp3", Sound.class);
		win = ctr.controller.get("data/music/win.ogg", Sound.class);
		lose = ctr.controller.get("data/music/lose.mp3", Sound.class);
		isLoadedMusic2 = true;
		isDeleteMusic2 = false;
		}
	}
	
	public void unloadMusic1(){
		if(isLoadedMusic1 == true){
			ctr.controller.unload("data/music/bgSlow.mp3");
			ctr.controller.unload("data/music/click.wav");
			bgSong.dispose();
			bgSong = null;
			yesSound.dispose();
			yesSound = null;
			noSound.dispose();
			noSound = null;
			isLoadedMusic1 = false;
		}
	}
	public void loadMusic1(){
		if(isLoadedMusic1 == false){
			ctr.controller.load("data/music/bgSlow.mp3", Music.class);
			ctr.controller.load("data/music/click.wav", Sound.class);
		}
	}
	public void loadedMusic1(){
		if(isLoadedMusic1 == false){
			bgSong = ctr.controller.get("data/music/bgSlow.mp3", Music.class);
			bgSong.setLooping(true);
			yesSound = ctr.controller.get("data/music/click.wav", Sound.class);
			noSound  = ctr.controller.get("data/music/click.wav", Sound.class);
			isLoadedMusic1 = true;
		}
	}
	
	public void loadGame(){		
		if(isLoadedGame == false){			
			ctr.controller.load("data/game/game.atlas", TextureAtlas.class);			
		}
	}
	public void loadedGame(){
		if(isLoadedGame == false || (isLoadedGame == true && isDeleteGame == true)){
			TextureAtlas gameAtlas = ctr.controller.get(ctr.g.ASSET_FOLDER_DATA + "game/game.atlas", TextureAtlas.class);			
			squareRegion = new TextureRegion[9];
			
			for (int i = 0; i < squareRegion.length; i++) {
				squareRegion[i] = gameAtlas.findRegion("square"+(i+1));
			}

			verRegion = gameAtlas.findRegion("ver");				
			horRegion = gameAtlas.findRegion("hoz");

			//
			bg1TL = gameAtlas.findRegion("1");
			bg1TR = new TextureRegion(bg1TL);
			bg1TR.flip(true, false);
			bg1BL = new TextureRegion(bg1TL);
			bg1BL.flip(false, true);
			bg1BR = new TextureRegion(bg1BL);
			bg1BR.flip(true, false);
			
			bg2WB = gameAtlas.findRegion("a1");
			bg2WL = gameAtlas.findRegion("a2");
			bg2WT = new TextureRegion(bg2WB);
			bg2WT.flip(false, true);
			bg2WR = new TextureRegion(bg2WL);
			bg2WR.flip(true, false);
			bg4Gome = gameAtlas.findRegion("Untitled-1");
			bg0Gome = gameAtlas.findRegion("2");
			conTL = gameAtlas.findRegion("corner");
			conTR = new TextureRegion(conTL);
			conTR.flip(true, false);
			conBL = new TextureRegion(conTL);
			conBL.flip(false, true);
			conBR = new TextureRegion(conBL);
			conBR.flip(true, false);
		//
			clockBound = gameAtlas.findRegion("lop-tren");
			clockCore  = gameAtlas.findRegion("lop-duoi");
			find = gameAtlas.findRegion("kinh-lap");
			swap = gameAtlas.findRegion("swap");		
			//			
		//
			String endFix = ctr.d.isVietnamese?"":"-en";
			bgCombo = gameAtlas.findRegion("combo");
			kha = gameAtlas.findRegion("combo1"+endFix);
			tot = gameAtlas.findRegion("combo2"+endFix);
			tuyetvoi = gameAtlas.findRegion("combo3"+endFix);
			hoanhao = gameAtlas.findRegion("text-hoanhao"+endFix);
		//		
			TextureRegion boom1Texture = gameAtlas.findRegion("effect21");
			boom1 = new TextureRegion[4];
			for (int i = 0; i < boom1.length; i++) {			
				boom1[i] = new TextureRegion(boom1Texture, i * 90, 0, 90, 90);
			}

			TextureRegion boom2Texture = gameAtlas.findRegion("effect22");
			boom2 = new TextureRegion[4];
			for (int i = 0; i < boom2.length; i++) {
				boom2[i] = new TextureRegion(boom2Texture, i * 90, 0, 90, 90);
			}

			TextureRegion boom3Texture = gameAtlas.findRegion("effect24");
			boom3 = new TextureRegion[4];
			for (int i = 0; i < boom3.length; i++) {
				boom3[i] = new TextureRegion(boom3Texture, i * 90, 0, 90, 90);
			}

			TextureRegion boom4Texture = gameAtlas.findRegion("effect22");
			boom4 = new TextureRegion[4];
			for (int i = 0; i < boom4.length; i++) {
				boom4[i] = new TextureRegion(boom4Texture, i * 90, 0, 90, 90);
			}

			TextureRegion boom5Texture = gameAtlas.findRegion("effect23");
			boom5 = new TextureRegion[4];
			for (int i = 0; i < boom5.length; i++) {
				boom5[i] = new TextureRegion(boom5Texture, i * 110, 0, 110, 110);
			}

			TextureRegion boom6Texture = gameAtlas.findRegion("effect26");
			boom6 = new TextureRegion[4];
			for (int i = 0; i < boom6.length; i++) {
				boom6[i] = new TextureRegion(boom6Texture, i * 110, 0, 110, 110);
			}
			//
			slash = new TextureRegion[7];
			for (int i = 0; i < slash.length; i++) {
				slash[i] = gameAtlas.findRegion("0"+(i+1));
			}
			//
			menuDialog_uof = gameAtlas.findRegion("menu");
			nextDialog_uof = gameAtlas.findRegion("next");
			replayDialog_uof = gameAtlas.findRegion("refresh");
			gomeLoseDialog_uof = gameAtlas.findRegion("lose");
			gomeWinDialog_uof = gameAtlas.findRegion("win");
						
			isLoadedGame = true;
			isDeleteGame = false;
		}
	}
	
	public void clearGame(){
		if(isDeleteGame == false){
			squareRegion = null;
			verRegion = null;				
			horRegion = null;
		//
			clockBound = null;
			clockCore  = null;
			find = null;
			swap = null;
			//
		//
			bgCombo = null;
			kha = null;
			tot = null;
			tuyetvoi = null;
			hoanhao = null;
		//		
			boom1 = null; 
			boom2 = null;
			boom3 = null;
			boom4 = null;
			boom5 = null;
			boom6 = null;
			slash = null;
			isDeleteGame = true;
		}
	}
	public void unloadGame(){
		if(isLoadedGame == true){			
			ctr.controller.unload(ctr.g.ASSET_FOLDER_DATA + "game/game.atlas");															
			clearGame();
			isLoadedGame = false;
		}
	}
	
	public void initBgIcon(){
		if(bgRegion==null)
			bgRegion = new TextureRegion[8];
		if(iconRegion == null)
			iconRegion = new TextureRegion[8][];
		if(isLoadedBg == null)
			isLoadedBg = new boolean[8];
		if(isLoadedIcon==null)
			isLoadedIcon = new boolean[8];
		if(isDeleteBg == null)
			isDeleteBg = new boolean[8];
		if(isDeleteIcon==null)
			isDeleteIcon = new boolean[8];
		if(nameRegionBg == null){
			nameRegionBg = new String[8];
			nameRegionBg[0] = "BG";
			nameRegionBg[1] = "04";
			nameRegionBg[2] = "02";
			nameRegionBg[3] = "03";
			nameRegionBg[4] = "05";
			nameRegionBg[5] = "07";
			nameRegionBg[6] = "01";		
			nameRegionBg[7] = "bg3";
		}
	}
	
	public void unloadAllBgAndIcon(){
		initBgIcon();
		for(int i=0;i<8;i++){
			if(isLoadedBg[i] == true){
				ctr.controller.unload(ctr.g.ASSET_FOLDER_DATA+"bg/bg"+(i)+".atlas");
				bgRegion[i] = null;
				isLoadedBg[i] = false;
			}
		}
		for(int i=0;i<8;i++){
			if(isLoadedIcon[i] == true){
				ctr.controller.unload(ctr.g.ASSET_FOLDER_DATA+"icon/icon"+(i)+".atlas");
				iconRegion[i] = null; 
				isLoadedIcon[i] = false;
			}
		}
		isLoadedBg = null;
		isLoadedIcon = null;
		isDeleteBg = null;
		isDeleteIcon = null;
		nameRegionBg = null;
		ctr.d.maxTypeIcon = null;
		bgRegion = null;
		iconRegion = null;
	}
	
	public void clearIcon(int chapter){
		initBgIcon();
		if(isDeleteIcon[chapter] == false){
			iconRegion[chapter] = null; 
			isDeleteIcon[chapter] = true;
		}
	}
	
	public void unloadIcon(int chapter){				
		initBgIcon();
		if(isLoadedIcon[chapter] == true){
			ctr.controller.unload(ctr.g.ASSET_FOLDER_DATA+"icon/icon"+(chapter)+".atlas");
			clearIcon(chapter);
			isLoadedIcon[chapter] = false;
		}
	}
	
	public void loadIcon(int chapter){		
		initBgIcon();
		if(isLoadedIcon[chapter] == false ){
			ctr.controller.load(ctr.g.ASSET_FOLDER_DATA+"icon/icon"+(chapter)+".atlas", TextureAtlas.class);
			//ctr.androidHelper.log("Step2. load"+chapter);
		}
	}
	
	public void loadedIcon(int chapter){		
		initBgIcon();		
		if(isLoadedIcon[chapter] == false|| (isLoadedIcon[chapter] == true && isDeleteIcon[chapter]==true)){
			TextureAtlas iconAtlas = ctr.controller.get(ctr.g.ASSET_FOLDER_DATA+"icon/icon"+(chapter)+".atlas");
			iconRegion[chapter] = new TextureRegion[ctr.d.maxTypeIcon[chapter]];
			for(int i=0;i<ctr.d.maxTypeIcon[chapter];i++){
				iconRegion[chapter][i] = iconAtlas.findRegion((((i+1)<10)?"0":"")+(i+1));
				//if(iconRegion[chapter][i] == null)
					//System.out.println("Cos cais null "+i);
			}
			isLoadedIcon[chapter] = true;
			isDeleteIcon[chapter] = false;
			//ctr.androidHelper.log("Step3. loaded"+chapter);
		}
	}

	public void clearBg(int chapter){
		initBgIcon();
		if(isDeleteBg[chapter] == false){
			bgRegion[chapter] = null;
			isDeleteBg[chapter] = true;
		}
	}
	public void unloadBg(int chapter){		
		initBgIcon();
		if(isLoadedBg[chapter] == true){
			ctr.controller.unload(ctr.g.ASSET_FOLDER_DATA+"bg/bg"+chapter+".atlas");
			clearBg(chapter);
			isLoadedBg[chapter] = false;
		}
	}
	public void loadBg(int chapter){	
		initBgIcon();
		if(isLoadedBg[chapter] == false){
			ctr.controller.load(ctr.g.ASSET_FOLDER_DATA+"bg/bg"+chapter+".atlas", TextureAtlas.class);
		}
	}
	public void loadedBg(int chapter){		
		initBgIcon();
		if(isLoadedBg[chapter] == false||(isLoadedBg[chapter] == true && isDeleteBg[chapter] == true)){
			TextureAtlas bgAtlas  = ctr.controller.get(ctr.g.ASSET_FOLDER_DATA+"bg/bg"+chapter+".atlas", TextureAtlas.class);
			bgRegion[chapter] = bgAtlas.findRegion(nameRegionBg[chapter]);
			isLoadedBg[chapter] = true;
			isDeleteBg[chapter] = false;
		}
	}
	
	public void clearDraw(){
		if(isDeleteDraw == false){
			bgDraw = null;
			//
			prev = null;
			next = null;
			boundSquare =  null;
			brush = null;
			eraser = null;
			football = null;
			cancel = null;
			grid = null;
			gomePainter = null;
			templateIcon = null;
			bgNameMap = null;
			fbShared = null;
			bgAllMap = null;
			isDeleteDraw = true;						
		}
	}
	
	public void unloadDraw(){
		if(isLoadedDraw == true){			
			//
			ctr.controller.unload(ctr.g.ASSET_FOLDER_DATA+"draw/draw.atlas");
			clearDraw();
			isLoadedDraw = false;
		}
	}
	public void loadDraw(){
		if(isLoadedDraw == false){			
			ctr.controller.load(ctr.g.ASSET_FOLDER_DATA+"draw/draw.atlas", TextureAtlas.class);
		}
	}
	public void loadedDraw(){
		if(isLoadedDraw == false||(isDeleteDraw == true && isLoadedDraw == true)){			
			//
			TextureAtlas drawAtlas = ctr.controller.get(ctr.g.ASSET_FOLDER_DATA+"draw/draw.atlas", TextureAtlas.class);
			bgDraw =  bgCommondRegion;
			//	
			prev = drawAtlas.findRegion("hide");
			next = new TextureRegion(prev);
			next.flip(true, false);
			boundSquare =  drawAtlas.findRegion("bitton2");
			brush = drawAtlas.findRegion("brush");
			eraser = drawAtlas.findRegion("eraser");
			football = drawAtlas.findRegion("football");
			cancel = drawAtlas.findRegion("cancel");
			grid = drawAtlas.findRegion("grid");
			if(ctr.d.isLDPI){
				grid.setRegionWidth(502);
				grid.setRegionHeight(301);
			}
			gomePainter = drawAtlas.findRegion("gome-draw");
			templateIcon = new TextureRegion[8];
			templateIcon[0] = drawAtlas.findRegion("cd6");
			templateIcon[1] = drawAtlas.findRegion("cd4");
			templateIcon[2] = drawAtlas.findRegion("cd1");
			templateIcon[3] = drawAtlas.findRegion("cd2");
			templateIcon[4] = drawAtlas.findRegion("cd5");
			templateIcon[5] = drawAtlas.findRegion("cd7");
			templateIcon[6] = drawAtlas.findRegion("cd3");
			templateIcon[7] = drawAtlas.findRegion("cd8");
			bgNameMap = drawAtlas.findRegion("btempt3");
			fbShared = drawAtlas.findRegion("fb-share");
			bgAllMap = drawAtlas.findRegion("BG");
			isLoadedDraw = true;
			isDeleteDraw = false;
		}
	}
	
	public void clearVS(){
		if(isDeleteVS == false){
			kiem_chem = null;
			iconBigGomeMoney = null;
			bgVSRegion = null;
			vRegion = null;
			sRegion = null;
			frameInfoRegion = null;
			balanceRegion = null;
			bigDiamond = null;
			sameRegion = null;
			bgItemBet = null;
			bgItemBetPress = null;
			betButton = null;
			isDeleteVS = true;
		}
	}
	public void unloadVS(){
		if(isLoadedVS == true){
			ctr.controller.unload(ctr.g.ASSET_FOLDER_DATA+"vs/vs.atlas");
			ctr.controller.unload("data/music/kiem_chem.mp3");
			//
			clearVS();
			isLoadedVS = false;
		}
	}
	public void loadVS(){
		if(isLoadedVS == false){
			ctr.controller.load(ctr.g.ASSET_FOLDER_DATA+"vs/vs.atlas", TextureAtlas.class);
			ctr.controller.load("data/music/kiem_chem.mp3", Sound.class);
		}
	}
	public void loadedVS(){
		if(isLoadedVS == false||(isLoadedVS == true && isDeleteVS == true)){
			kiem_chem = ctr.controller.get("data/music/kiem_chem.mp3", Sound.class);
			TextureAtlas vsAtlas = ctr.controller.get(ctr.g.ASSET_FOLDER_DATA+"vs/vs.atlas", TextureAtlas.class);
			iconBigGomeMoney = vsAtlas.findRegion("32");
			//
			bgVSRegion = bgCommondRegion;
			vRegion = vsAtlas.findRegion("vs-v");
			sRegion = vsAtlas.findRegion("vs-s");
			frameInfoRegion = vsAtlas.findRegion("bang-thongtin");
			balanceRegion = vsAtlas.findRegion("libra");
			bigDiamond = vsAtlas.findRegion("diamond");
			sameRegion = vsAtlas.findRegion("trade");
			bgItemBet = vsAtlas.findRegion("boder");
			bgItemBetPress = vsAtlas.findRegion("boder0");
			betButton = vsAtlas.findRegion("ca-cuoc");
			isLoadedVS = true;
			isDeleteVS = false;
		}
	}
	
	public void clearLevel(){
		if(isDeleteLevel == false){
			ball0Region = null;
			ball1Region = null;
			ball2Region = null;
			ball3Region = null;
			ball4Region = null;
			ball5Region = null;
			ball6Region = null;
			isDeleteLevel = true;
		}		
	}
	public void unloadLevel(){	
		if(isLoadedLevel == true){
			ctr.controller.unload(ctr.g.ASSET_FOLDER_DATA + "level/level.atlas");	
			clearLevel();
			isLoadedLevel = false;
		}
	}
	
	public void loadLevel(){		
		if(isLoadedLevel == false){
			ctr.controller.load(ctr.g.ASSET_FOLDER_DATA + "level/level.atlas", TextureAtlas.class);	
		}
	}
	
	public void loadedLevel(){
		if(isLoadedLevel == false||(isDeleteLevel == true && isLoadedLevel == true)){
			isLoadedLevel = true;
			TextureAtlas levelAtlas = ctr.controller.get(ctr.g.ASSET_FOLDER_DATA + "level/level.atlas", TextureAtlas.class);
			ball0Region = levelAtlas.findRegion("pokeball");
			ball1Region = levelAtlas.findRegion("pokeball1");
			ball2Region = levelAtlas.findRegion("pokeball2");
			ball3Region = levelAtlas.findRegion("pokeball1");
			ball4Region = levelAtlas.findRegion("pokeball2");
			ball5Region = levelAtlas.findRegion("pokeball1");
			ball6Region = levelAtlas.findRegion("pokeball2");
			isDeleteLevel = false;
		}
	}
	public void clearChapter(){
		if(isDeleteChapter == false){
			iconLockChapterRegion = null;
			pika1Region = null;
			pika2Region = null;
			pika3Region = null;
			pika4Region = null;
			pika5Region = null;
			pika6Region = null;
			pika7Region = null;
			pika8Region = null; 
			isDeleteChapter = true;
		}
	}
	public void unloadChapter(){
		if(isLoadedChapter == true){
			ctr.controller.unload(ctr.g.ASSET_FOLDER_DATA + "chapter/chapter.atlas");	
			clearChapter();
			isLoadedChapter = false;
		}
	}
	
	public void loadChapter () {
		if(isLoadedChapter == false){
			ctr.controller.load(ctr.g.ASSET_FOLDER_DATA + "chapter/chapter.atlas", TextureAtlas.class);	
		}
	}
	
	public void loadedChapter () {
		if(isLoadedChapter == false || (isLoadedChapter == true && isDeleteChapter == true)){
		TextureAtlas chapterAtlas = ctr.controller.get(ctr.g.ASSET_FOLDER_DATA+"chapter/chapter.atlas", TextureAtlas.class);
		iconLockChapterRegion = chapterAtlas.findRegion("lock");
		pika1Region = chapterAtlas.findRegion("candy");
		pika2Region = chapterAtlas.findRegion("go-to-school");
		pika3Region = chapterAtlas.findRegion("trau");
		pika4Region = chapterAtlas.findRegion("singer");
		pika5Region = chapterAtlas.findRegion("exsoccer");
		pika6Region = chapterAtlas.findRegion("car");
		pika7Region = chapterAtlas.findRegion("love");
		pika8Region = chapterAtlas.findRegion("noel");
		isDeleteChapter = false;
		isLoadedChapter = true;
		}
	}
	
	public void unloadCommond2(){
		if(isLoadedCommond2 == true){
		isLoadedCommond2 = false;
		ctr.controller.unload(ctr.g.ASSET_FOLDER_DATA+"commond/commond2.atlas");
		ctr.controller.unload(ctr.g.ASSET_FOLDER_DATA+"combo.png");
		
		avatarFrame = null;
		if(avatarTexture!=null)
			avatarTexture.dispose();
		avatarTexture = null;
		
		if(avatarBossTexture!=null)
			avatarBossTexture.dispose();
		avatarBossTexture = null;
		
		avatarDefault = null;
		avatarMe = null;
		avatarBoss = null;
		fbAttackIcon = null;
		iconGomeMoney = null;
		bgCommondRegion = null;
		iconSmallGome = null;
		
		downloadNorRegion = null;
		downloadPressRegion = null;	
		//
		exitNorRegion = null;
		exitPressRegion = null;	
		//
		sharedNorRegion = null;
		sharedPressRegion = null;	
		//
		cuponNor = null;
		cuponPress = null;
		//
		updateIcon = null;
		//
		shopButtonNor = null;
		shopButtonPress = null;
		changeAvatarNor = null;
		changeAvatarPress = null;
		askFBNor = null;
		askFBPress = null;
		addGoldNor = null;
		addGoldPress = null;
		//
		infoNorRegion = null;
		infoPressRegion = null;	
		//
		friendNorRegion = null;
		friendPressRegion = null;
		//
		settingRegion = null;
		//
		sms = null;
		smsPress = null;
		bank = null;
		bankPress = null;
		scratch = null;
		scratchPress = null;
		paypal = null;
		paypalPress = null;
		
		resetPass = null;
		resetPass2 = null;
		//
		arrowDown = null;
		arrowLeft = null;
		sticky = null;
		ok = null;
		star = null;
		hand = null;
		//
		achievement = null;
		//
		bgItemHelp = null;
		topUser = null;
		closeDialog = null;
		onlineGomeMoney = null;
		gomeShopIcon = null;
		elGPPay = null;
		elGPPayPress = null;
		oneGomeMoney = null;
		buyMoney = null;
		twoGomeMoney = null;
		threeGomeMoney = null;
		fourGomeMoney = null;
		boderAvatar = null;
		bgDialog_uof = null;
		menuDialog_uof = null;
		nextDialog_uof = null;
		replayDialog_uof = null;
		gomeLoseDialog_uof = null;
		gomeWinDialog_uof = null;
		//
		loginBgDialog_uof = null;
		loginNorDialog_uof = null;
		loginPressDialog_uof = null;
		regNorDialog_uof = null;
		regPressDialog_uof = null;
		
		buttonBlank = null;
		
		okNorRegion = null;
		okPressRegion = null;
		
		noNorRegion = null;
		noPressRegion = null;
		
		loginPopUpNor = null;
		loginPopUpPress = null;
		shareFb = null;
		shareFBPress = null;
		nameGame = null;
		topText = null;
		logoutPopUpNor = null;
		logoutPopUpPress = null;
		bgDialogNoBoder = null;
		blankSmallButton = null;
		settingIcon = null;
		
		starRegion = null;
		
		bgAchieve = null;
		
		textBet = null;
		textBetPress = null;
		
		onlineNorRegion = null;
		onlinePressRegion = null;
		
		playNorRegion = null;
		playPressRegion = null;
		
		specialNorRegion = null;
		specialPressRegion = null;
		
		vsNorRegion = null;
		vsPressRegion = null;
		
		createMapNor = null;
		createMapPress = null;
		}
	}
	
	public void loadCommond2 () {
		if(isLoadedCommond2 == false)
		{
			ctr.controller.load(ctr.g.ASSET_FOLDER_DATA + "commond/commond2.atlas", TextureAtlas.class);
			ctr.controller.load("data/commond/text.atlas", TextureAtlas.class);
			if(ctr.d.isVietnamese){
				ctr.controller.load(ctr.g.ASSET_FOLDER_DATA + "commond/text-vi.atlas", TextureAtlas.class);
			}
			else{				
				ctr.controller.load(ctr.g.ASSET_FOLDER_DATA + "commond/text-en.atlas", TextureAtlas.class);
			}
			ctr.controller.load(ctr.g.ASSET_FOLDER_DATA + "combo.png", Texture.class);
			ctr.controller.load(ctr.g.ASSET_FOLDER_DATA + "abc.png", Texture.class);
		}
	}
	
	public void loadedCommond2 () {
		if(isLoadedCommond2 == false){
		TextureAtlas cm2Atlas = ctr.controller.get(ctr.g.ASSET_FOLDER_DATA+"commond/commond2.atlas", TextureAtlas.class);
		
		TextureAtlas textCommonAtlas = ctr.controller.get("data/commond/text.atlas", TextureAtlas.class);
		TextureAtlas textAtlas;
		if(ctr.d.isVietnamese){
			textAtlas = ctr.controller.get(ctr.g.ASSET_FOLDER_DATA+"commond/text-vi.atlas", TextureAtlas.class);
		}
		else{
			textAtlas = ctr.controller.get(ctr.g.ASSET_FOLDER_DATA+"commond/text-en.atlas", TextureAtlas.class);
		}
		
		Texture comboTexture = ctr.controller.get(ctr.g.ASSET_FOLDER_DATA+"combo.png", Texture.class);
		comboTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
		ctr.g.mFontCombo = new BitmapFont(Gdx.files.internal("data/combo.fnt"), new TextureRegion(comboTexture), false);
		
		Texture abcTexture = ctr.controller.get(ctr.g.ASSET_FOLDER_DATA+"abc.png", Texture.class);
		abcTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
		ctr.g.mFontAbc = new BitmapFont(Gdx.files.internal("data/abc.fnt"), new TextureRegion(abcTexture), false);

		
		avatarFrame =  cm2Atlas.findRegion("bill");
		//		
		avatarMe = cm2Atlas.findRegion("avatar");	
		avatarMe.setRegionWidth(64);
		avatarMe.setRegionHeight(64);
		
		avatarDefault = cm2Atlas.findRegion("avatar");	
		avatarDefault.setRegionWidth(64);
		avatarDefault.setRegionHeight(64);
		
		avatarBoss = cm2Atlas.findRegion("avatar");
		avatarBoss.setRegionWidth(64);
		avatarBoss.setRegionHeight(64);
		try{
		avatarTexture = new Texture(Gdx.files.external("data/avatar/"+ctr.d.name));
		}
		catch(Exception ex)
		{
			avatarTexture = null;
		}
		if(ctr.d.isHasAccount && avatarTexture!=null){
			avatarMe = new TextureRegion(avatarTexture);
		}
		
		//
		fbAttackIcon = cm2Atlas.findRegion("face");
		iconGomeMoney = cm2Atlas.findRegion("gold");
		bgCommondRegion = cm2Atlas.findRegion("BG");
		iconSmallGome = cm2Atlas.findRegion("chim2");
				
		downloadNorRegion = cm2Atlas.findRegion("help");
		downloadPressRegion = cm2Atlas.findRegion("help");	
		//
		exitNorRegion = cm2Atlas.findRegion("volume");
		exitPressRegion = cm2Atlas.findRegion("volume");	
		//
		sharedNorRegion = cm2Atlas.findRegion("help");
		sharedPressRegion = cm2Atlas.findRegion("help");	
		//
		updateIcon = cm2Atlas.findRegion("icon-updates");
		//
		shopButtonNor = cm2Atlas.findRegion("plus");
		shopButtonPress = cm2Atlas.findRegion("plus-press");
		//=========Text		
		
		askFBNor = textCommonAtlas.findRegion("ask-f-button");
		askFBPress = textCommonAtlas.findRegion("add-f-button-press");
		
		changeAvatarNor = textCommonAtlas.findRegion("change-avatar-button");
		changeAvatarPress = textCommonAtlas.findRegion("change-avatar-button-press");
				
		bank = textCommonAtlas.findRegion("bank-card");
		bankPress = textCommonAtlas.findRegion("bank-card-press");
		
		resetPass = textCommonAtlas.findRegion("reset");
		resetPass2 = textCommonAtlas.findRegion("reset-press");
		
		sms = textCommonAtlas.findRegion("sms");
		smsPress = textCommonAtlas.findRegion("sms-press");
		
		scratch = textCommonAtlas.findRegion("scratch-card");
		scratchPress = textCommonAtlas.findRegion("scratch-card-press");
		
		paypal = textCommonAtlas.findRegion("paypal");
		paypalPress = textCommonAtlas.findRegion("paypal-press");
		
		cuponNor = textCommonAtlas.findRegion("coupon-button");
		cuponPress = textCommonAtlas.findRegion("coupon-button-press");
		
		shareFb = textCommonAtlas.findRegion("share");
		shareFBPress = textCommonAtlas.findRegion("share-press");
		//
		addGoldNor = textAtlas.findRegion("add-gold-button");
		addGoldPress = textAtlas.findRegion("add-gold-button-press");
		
		loginPopUpNor = textAtlas.findRegion("dangnhap");
		loginPopUpPress = textAtlas.findRegion("dangnhap-press");
		
		logoutPopUpNor = textAtlas.findRegion("dangxuat");
		logoutPopUpPress = textAtlas.findRegion("dangxuat-press");

		loginNorDialog_uof = textAtlas.findRegion("dn1");
		loginPressDialog_uof = textAtlas.findRegion("dn2");
		
		regNorDialog_uof = textAtlas.findRegion("dk1");
		regPressDialog_uof = textAtlas.findRegion("dk2");
		
		okNorRegion = textAtlas.findRegion("dongy");
		okPressRegion = textAtlas.findRegion("dongy2");
		
		noNorRegion = textAtlas.findRegion("huy");
		noPressRegion = textAtlas.findRegion("huy2");
				
		topText = textAtlas.findRegion("top");
		
		textBet = textAtlas.findRegion("cuoc");
		textBetPress = textAtlas.findRegion("datcuoc-press");
		
		onlineNorRegion = textAtlas.findRegion("doi-khang");
		onlinePressRegion = textAtlas.findRegion("doi-khang");
		
		playNorRegion = textAtlas.findRegion("choi");
		playPressRegion = textAtlas.findRegion("choi");
		
		specialNorRegion = textAtlas.findRegion("nang-khieu");
		specialPressRegion = textAtlas.findRegion("nang-khieu");
		
		vsNorRegion = textAtlas.findRegion("nut-dau");
		vsPressRegion = textAtlas.findRegion("nut-dau-prs");
		
		createMapNor = textAtlas.findRegion("new");
		createMapPress = textAtlas.findRegion("new2");
		//===============
		
		infoNorRegion = cm2Atlas.findRegion("info");
		infoPressRegion = cm2Atlas.findRegion("info");	
		
		//
		friendNorRegion = cm2Atlas.findRegion("music");
		friendPressRegion = cm2Atlas.findRegion("music");
		//
		settingRegion = cm2Atlas.findRegion("setting");
		starRegion = cm2Atlas.findRegion("star");
		//
		//
		achievement = new TextureRegion[5];
		achievement[0] = cm2Atlas.findRegion("1");
		achievement[1] = cm2Atlas.findRegion("2");
		achievement[2] = cm2Atlas.findRegion("3");
		achievement[3] = cm2Atlas.findRegion("4");
		achievement[4] = cm2Atlas.findRegion("5");		
		//
		star = new TextureRegion[5];
		star[0] = cm2Atlas.findRegion("1star");
		star[1] = cm2Atlas.findRegion("2star");
		star[2] = cm2Atlas.findRegion("3star");
		star[3] = cm2Atlas.findRegion("4star");
		star[4] = cm2Atlas.findRegion("5star");		
		hand = cm2Atlas.findRegion("hand2");
		arrowLeft = cm2Atlas.findRegion("left");
		arrowDown = cm2Atlas.findRegion("down");
		sticky = cm2Atlas.findRegion("sticky");
		ok = cm2Atlas.findRegion("ok");
		//
		bgItemHelp = cm2Atlas.findRegion("bill-04");
		topUser = cm2Atlas.findRegion("top cao thu");
		closeDialog = cm2Atlas.findRegion("cancel");
		onlineGomeMoney = cm2Atlas.findRegion("diamond-small");
		gomeShopIcon = cm2Atlas.findRegion("shop-sale");
		oneGomeMoney = cm2Atlas.findRegion("1gold");
		buyMoney = cm2Atlas.findRegion("buy");
		twoGomeMoney = cm2Atlas.findRegion("2gold");
		threeGomeMoney = cm2Atlas.findRegion("3gold");
		fourGomeMoney = cm2Atlas.findRegion("4gold");
		elGPPay = cm2Atlas.findRegion("boder2");
		elGPPayPress = cm2Atlas.findRegion("boder21");
		boderAvatar = cm2Atlas.findRegion("boder-avt");
		bgDialog_uof = cm2Atlas.findRegion("board");
		menuDialog_uof = cm2Atlas.findRegion("menu");
		nextDialog_uof = cm2Atlas.findRegion("next");
		replayDialog_uof = cm2Atlas.findRegion("refresh");
		gomeLoseDialog_uof = cm2Atlas.findRegion("lose");
		gomeWinDialog_uof = cm2Atlas.findRegion("win");
		//
		buttonBlank = cm2Atlas.findRegion("btempt3");
		loginBgDialog_uof = cm2Atlas.findRegion("login");
				
		nameGame = cm2Atlas.findRegion("Brand-name");		
		bgAchieve = cm2Atlas.findRegion("frame1");
		blankSmallButton = cm2Atlas.findRegion("bitton2");
		settingIcon = cm2Atlas.findRegion("setting-rotation");
		bgDialogNoBoder = new TextureRegion(bgDialog_uof, 0, 0, 483, 273);
		
		isLoadedCommond2 = true;
		}
	}
	
	public void clearMenu(){		
		if(isDeleteMenu == false){
		bgMenu = null;
		logoRegion = null;
		//
		facebook = null;
		//
		isDeleteMenu = true;
		}
	}
	
	public void unloadMenu () {
		if(isLoadedMenu == true){
			isLoadedMenu = false;
		ctr.controller.unload(ctr.g.ASSET_FOLDER_DATA + "menu/menu.atlas");
		clearMenu();
		}
	}
	
	public void loadMenu () {
		if(isLoadedMenu == false){
		ctr.controller.load(ctr.g.ASSET_FOLDER_DATA + "menu/menu.atlas", TextureAtlas.class);
		}
		//
	}
	
	public void loadedMenu () {
		if(isLoadedMenu == false || (isLoadedMenu == true && isDeleteMenu == true)){
			isLoadedMenu = true;
			isDeleteMenu = false;
		TextureAtlas menuAtlas = ctr.controller.get(ctr.g.ASSET_FOLDER_DATA+"menu/menu.atlas", TextureAtlas.class);
		bgMenu = menuAtlas.findRegion("BG");
		logoRegion = menuAtlas.findRegion("zegome");
		//
		facebook = menuAtlas.findRegion("face");	
		fbShareMenu = menuAtlas.findRegion("facebook-link");
		//
		}
	}
	
	public void unloadCommond1(){
		if(isLoadedCommond1 == true){
		if(ctr.controller.isLoaded(ctr.g.ASSET_FOLDER_DATA + "commond/commond1.atlas"))
			ctr.controller.unload(ctr.g.ASSET_FOLDER_DATA + "commond/commond1.atlas");
		ctr.controller.unload(ctr.g.ASSET_FOLDER_DATA+"default.png");
		transRegion = null;
		blackRegion = null;
		isLoadedCommond1 = false;
		}
	}
	
	public void unloadSplash()
	{		
		if(isLoadedSplash == true){
		if(splash1!=null)
			splash1.dispose();
		if(splash2!=null)
			splash2.dispose();
		if(splash3!=null)
			splash3.dispose();
		splash1 = null;
		splash2 = null;
		splash3 = null;		
		//		
		bgSplash = null;		
		logoSplash = null;
		//
		isLoadedSplash = false;
		}
	}
	
	public void loadSplash()
	{
		if(isLoadedCommond1 == false){
		ctr.controller.load(ctr.g.ASSET_FOLDER_DATA + "commond/commond1.atlas", TextureAtlas.class);
		ctr.controller.load("data/default.png", Texture.class);
		}
		//
		if(isLoadedSplash == false){
		}
		//
	}
	//
	public void loadedSplash()
	{	
		if(isLoadedCommond1 == false){
		//
		TextureAtlas cm1Atlas = ctr.controller.get(ctr.g.ASSET_FOLDER_DATA+"commond/commond1.atlas", TextureAtlas.class);
		transRegion = cm1Atlas.findRegion("trans");
		blackRegion = cm1Atlas.findRegion("black");
		isLoadedCommond1 = true;
		Texture font = ctr.controller.get(ctr.g.ASSET_FOLDER_DATA+"default.png",Texture.class);
		font.setFilter(TextureFilter.Linear, TextureFilter.Linear);
		ctr.g.mFont = new BitmapFont(Gdx.files.internal("data/default.fnt"), new TextureRegion(font), false);
		ctr.g.mFont.setScale(0.80f);
		final TextField inputq = new TextField("", ctr.g.mSkin);	
		inputq.getStyle().font = ctr.g.mFont;
		}
		//		
		if(isLoadedSplash == false){
		isLoadedSplash = true;		
		}
		//
	}
	//	
	public float vls=1f;
	//
	public void soundOnOff(){
		
		//ExternalFileEncrypt es = new ExternalFileEncrypt(context, , name);
		//es.savaData(key, data);
		
	    
		
		if(ctr.d.isMusic){
			if(bgSong!=null)
				bgSong.setVolume(1f);
			if(mainSong!=null)
				mainSong.setVolume(1f);			
		}
		else{
			if(bgSong!=null)
				bgSong.setVolume(0f);
			if(mainSong!=null)
				mainSong.setVolume(0f);

		}
		
		if(ctr.d.isSound){
			vls = 1f;
		}
		else{
			vls = 0f;
		}
	}
	
	public void musicStop(){
		
		//if(ctr.d.isMusic){
			if(bgSong!=null)
				bgSong.stop();
			if(mainSong!=null)
				mainSong.stop();
	}
	//
	
	public boolean isDialogCloseStyle(){
		return(!isHasDialog.isEmpty()&&isHasDialog.elementAt(isHasDialog.size()-1)==0);
	}
	
	public boolean isHasDialog(){
		return (!isHasDialog.isEmpty() || isFadeScreen);
	}
	
	public void reset(){
		isHasDialog = new Vector<Integer>();	
		isFadeScreen = false;
		vls = 1f;
	}
	//================NOTIFY=============
	//================DIALOG============
	public Vector<Integer> isHasDialog;
	public boolean isFadeScreen = true;
	public boolean isFbAction;
	//
	public void unloadOther(){		
		isFadeScreen = false;
		isHasDialog.removeAllElements();
		isHasDialog = null;
		vls = 1f;
	}
}